﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;

namespace Sustainalytics.Universes.Service.Tests
{
    [TestClass]
    public class UniversesControllerTests
    {
        public static bool StreamsAreIdentical(Stream a, Stream b)
        {
            if (a.Length != b.Length)
                return false;

            a.Position = 0;
            b.Position = 0;

            var buffer1 = new byte[65535];
            var buffer2 = new byte[65535];

            for (var i = 0; i < a.Length; i++)
            {
                var found1 = a.Read(buffer1, 0, 65535);
                var found2 = b.Read(buffer2, 0, 65535);

                if (found1 != found2)
                    return false;

                for (var j = 0; j < found1; j++)
                    if (buffer1[j] != buffer2[j])
                        return false;
            }
            return true;
        }
    }
}
